Skip to content

BUG: to_numeric(errors='coerce', dtype_backend='pyarrow') with ArrowDtype #52606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 11, 2023

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke commented Apr 11, 2023

@mroeschke mroeschke added the Arrow pyarrow functionality label Apr 11, 2023
@mroeschke mroeschke added this to the 2.0.1 milestone Apr 11, 2023
@mroeschke mroeschke requested a review from phofl April 11, 2023 20:38
@@ -275,7 +275,8 @@ def to_numeric(
# GH33013: for IntegerArray, BooleanArray & FloatingArray need to reconstruct
# masked array
if (mask is not None or new_mask is not None) and not is_string_dtype(values.dtype):
if mask is None:
if mask is None or (new_mask is not None and errors == "coerce"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't really think about a case right now, but I think new_mask.shape == mask.shape instead of errors="coerce" is safer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I'll change it to that

@@ -275,7 +275,9 @@ def to_numeric(
# GH33013: for IntegerArray, BooleanArray & FloatingArray need to reconstruct
# masked array
if (mask is not None or new_mask is not None) and not is_string_dtype(values.dtype):
if mask is None or (new_mask is not None and errors == "coerce"):
if mask is None or (
mask is not None and new_mask is not None and new_mask.shape == mask.shape
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove the mask is not None, this is covered by the first condition

@mroeschke mroeschke merged commit 471c852 into pandas-dev:main Apr 11, 2023
@mroeschke mroeschke deleted the bug/to_numeric/arrow branch April 11, 2023 23:09
@lumberbot-app
Copy link

lumberbot-app bot commented Apr 11, 2023

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 2.0.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 471c852b3c7c665e4d45b3109cab2b79582a8f6d
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am "Backport PR #52606: BUG: to_numeric(errors='coerce', dtype_backend='pyarrow') with ArrowDtype"
  1. Push to a named branch:
git push YOURFORK 2.0.x:auto-backport-of-pr-52606-on-2.0.x
  1. Create a PR against branch 2.0.x, I would have named this PR:

"Backport PR #52606 on branch 2.0.x (BUG: to_numeric(errors='coerce', dtype_backend='pyarrow') with ArrowDtype)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@mroeschke
Copy link
Member Author

@meeseeksmachine backport 2.0.x

@mroeschke
Copy link
Member Author

@meeseeksdev backport 2.0.x

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Apr 11, 2023
phofl pushed a commit that referenced this pull request Apr 12, 2023
…dtype_backend='pyarrow') with ArrowDtype) (#52611)

Backport PR #52606: BUG: to_numeric(errors='coerce', dtype_backend='pyarrow') with ArrowDtype

Co-authored-by: Matthew Roeschke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: pd.to_numeric(.., dtype_backend='pyarrow') crashes for string[pyarrow]
2 participants